using System;

namespace Headspring.Training.Core.Model
{
	public class Employee
	{
		public Employee()
		{
			PasswordHash = "";
			PasswordSalt = "";
			HomeAddress = new Address();
		}

		public Employee(string userName, string firstName, string lastName,
		                string emailAddress) : this()
		{
			UserName = userName;
			FirstName = firstName;
			LastName = lastName;
			EmailAddress = emailAddress;
		}

		public virtual Guid Id { get; set; }
		public virtual string UserName { get; set; }
		public virtual string PasswordHash { get; set; }
		public virtual string PasswordSalt { get; set; }
		public virtual string FirstName { get; set; }
		public virtual string LastName { get; set; }
		public virtual string EmailAddress { get; set; }
		public virtual Manager Manager { get; set; }
		public virtual Address HomeAddress { get; set; }

		public virtual string GetFullName()
		{
			return string.Format("{0} {1}", FirstName, LastName);
		}

		public override string ToString()
		{
			return GetFullName();
		}

		public virtual int CompareTo(Employee other)
		{
			int compareResult = LastName.CompareTo(other.LastName);
			if (compareResult == 0)
			{
				compareResult = FirstName.CompareTo(other.FirstName);
			}

			return compareResult;
		}

		public virtual string GetRejectEmail(DayOfWeek dayOfWeek)
		{
			return EmailAddress;
		}

		public virtual bool ReportsTo(Employee compareEmployee)
		{
			if (Manager == null)
				return false;
			else
				return Manager.Id.Equals(compareEmployee.Id);
		}
	}
}